<div class="maintop">
    当前位置：站内信 - 发件箱
    <a href="javascript:;" action="/box/mail_add" class="mainFrame button icon-plus">写信</a>
    <a href="javascript:;" action="<?=$basepath?>?<?=$page_url?>" class="mainFrame button" id="btn_refresh">刷新</a>
    <? if(ISDEBUG){ ?>
        <a href="javascript:$('.debuginfo').toggle();" class="button">调试信息</a>
    <? } ?>
</div>
<div class="main-search">
    <table width="100%">
        <tbody><tr>
            <td>
                <form action="<?=$basepath?>" id="SearchForm" method="get" target="ajax" dataType="html" onajax="beforeSearchForm" call="searchForm" container="#iframe" isLoad="true">
                    <input type="text" id="sKey" name="sKey" class="int" placeholder="搜索关键字">
                    注册日期：从
                    <input id="fromTime" name="fromTime" type="text" class='Wdate' style='width:100px;' value="<?=$searchdata['fromTime']?date('Y-m-d',intval(strtotime($searchdata['fromTime']))):''?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"></input>&nbsp;至
                    <input id="toTime" name="toTime" type="text" class='Wdate' style='width:100px;' value="<?=$searchdata['toTime']?date('Y-m-d',intval(strtotime($searchdata['toTime']))):''?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"></input>&nbsp;&nbsp;
                    <input type="submit" value="搜索" class="upbutton">
                </form>
            </td>
        </tr>
        </tbody>

    </table>
</div>
<div id="mainbody">
    <table width="100%" class="tablist">
        <tr class="trbg">
            <th>No.</th>
            <th>主题</th>
            <th>日期时间</th>
            <th>接收方</th>
            <th width="40">操作</th>
        </tr>
        <? foreach($datas as $v){
            if($v['touid']) {
                $sql = 'SELECT GROUP_CONCAT(uno,\'-\',nickname) AS uno FROM `@@users` WHERE `uid` IN(SELECT group_concat(uid) FROM `@@mailbox_user` WHERE `forid`=' . $v['id'].')';
                $uids = $this->db->query($sql, 2);
                $uids = $uids['uno'];
            }
            ?>
            <tr>
                <td><?=$v['id']?></td>
                <td><?=$v['title']?></td>
                <td><?=$this->formatTimes($v['actiontime'])?></td>
                <td><?=($v['touid']?$uids:'所有人')?></td>
                <td>
                    <a action="<?=$basepath?>_delete?id=<?=$v['id']?>&title=<?=$v['title']?>&<?=$page_url?>" title="删除" class="mainFrame button icon-trash-2" href="javascript:;"></a>
                </td>
            </tr>
        <? } ?>
    </table>
    <? require VIEW.'/page.view.php' ?>
</div>
<script type="text/javascript">
    function beforeSearchForm(){

    }
    function searchForm(self, _html, data){
        $("#iframe").html(_html);
    }
    $(document).ready(function(){
        <?php
        if(!empty($searchdata['sKey'])){
            echo '$("#sKey").val("'.$searchdata['sKey'].'");';
        }
        ?>
        $(".colorbox").colorbox({ iframe: true,width:"100%",height:"100%" });
    });
</script>
